USE KrisFlyerKB
go
select distinct qm.QuizMasterID, qm.QuizDate, qm.QuizMaster, qm.QuizDesc, qm.NumberQuestion, qm.TimeLimit from tblQuizMaster qm 
                inner join tblQuizMasterAccess qma on qm.QuizMasterID = qma.QuizMasterID 
                inner join tblUserGroupAccess uga on uga.GroupAccessID = qma.GroupAccessID 
                inner join tblGroupMasterLink gml on gml.QuizMasterID = qm.QuizMasterID 
                where qm.isActive = 1 and uga.PPersonCode = @ppersoncode
                and gml.QuizGroupID = @quizgroupid and uga.PCampaign = @pcampaign and YEAR(qm.QuizDate) = @year and qma.isEnabled = 1 and uga.isEnabled = 1 order by qm.QuizDate desc;

--ADD LINK to tblGroupMasterLink According to Quiz Group
--View New Quiz 
select * from tblquizmaster Order By QuizMasterID DESC
--View Group ID
select * from tblquizgroup 
--Check Link
select * From tblGroupMasterLink
Where QuizGroupID = 5
--Insert New Link
--Insert Into tblGroupMasterLink Values(5,85)